<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>流程图形化</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmultateIE7" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/js/dojo191/dijit/themes/soria/soria.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/js/dojo191/dojox/layout/resources/ExpandoPane.css" />
<script src="${pageContext.request.contextPath}/js/dojo191/dojo/dojo.js"
	type='text/javascript' djConfig="parseOnLoad:true"></script>
<script>
	var BasePath = '${pageContext.request.contextPath}/js/workflow';
</script>
<script
	src="${pageContext.request.contextPath}/js/workflow/js/Client-mini.js"
	type='text/javascript'></script>
<script
	src="${pageContext.request.contextPath}/js/workflow/js/common-mini.js"
	language='JavaScript' type='text/javascript'></script>

<style type="text/css">
form {
	margin: 0;
	padding: 0 1px
}

#nodeDlg table,#nodeDlg fieldset {
	text-align: center
}

#nodeDlg table {
	width: 460px;
	margin: 10px 5px
}

#nodeDlg tr {
	height: 30px
}

#nodeDlg td input {
	width: 95%
}

#contain {
	position: relative
}

#contain input {
	display: block;
	position: absolute;
	left: 0;
	top: 0;
	border-right: 0;
	z-index: 100
}

#contain select {
	display: block;
	text-align: center;
	z-index: 1
}

#oWinDlg .dijitDialogPaneContent,#oMustTipDlg .dijitDialogPaneContent,#oSelectDlg .dijitDialogPaneContent,#oFieldDlg.dijitDialogPaneContent
	{
	padding: 0
}

.tbWFFormContainer {
	width: 480px;
	padding: 10px 0
}

#WFFormContainer {
	height: 400px;
	width: 442px;
	overflow-y: auto
}

#WFFormContainer .dvAllIdea {
	float: left;
	margin: 1px 1px;
	width: 210px;
}

#WFFormContainer .dvAllIdea table {
	width: 100%;
	border: 1px solid #888;
	font-size: 12px
}

#WFFormContainer .dvAllIdea table tr td {
	width: 100%;
	border: 1px solid #888;
	text-valign: middle
}

#WFFormContainer .tdTitle {
	font-weight: bold;
	text-indent: 5px;
	background-color: #ffc;
	width: 100px;
}

#WFFormContainer .tdInput {
	padding: 2px;
	padding-left: 5px;
	line-height: 20px;
	width: 100px;
}
</style>
<script language="JavaScript" type="text/javascript">
	require([ "dojo/data/ItemFileReadStore" ]);
	<!--
	dojo.addOnLoad(function() {
		/*
		 var url= '/'+gCurDB+'/(agtModelJSON)?openagent';
		 dojo.xhrGet({
		 url:url,
		 preventCache:true,
		 handleAs:'json',
		 load:function(obj){
		 dojo.byId('WFModule').add(new Option("",""));
		 if(obj.length>0){
		 var op="";
		 for(var i=0;i<obj.length;i++){//obj[i].db
		 op=new Option(obj[i].text,obj[i].text);
		 dojo.setAttr(op,"db",obj[i].db);
		 dojo.byId('WFModule').add(op);
		 }
		 dojo.byId('WFModule').value=gWFModule;
		 }
		 }
		 });
		 */
	});

	function fnDelWF(id) {
		if (confirm("确定删除该流程吗？")) {
			dojo.xhrGet({
				url : "/" + gCurDB + "/agtDelWF?OpenAgent&ID=" + id,
				handleAs : "text",
				preventCache : true,
				load : function(txt) {
					if (parseInt(txt) == 1) {
						OpenWF()
					}
					dijit.byId('oWFDlg').onCancel();
				},
				error : function(response) {
					alert("无法删除，可能服务器异常或网络不通！");
				}
			})
		}
	}
	function fnReplicateWF(id) {
		if (confirm("确定复制该流程吗？")) {
			dojo.xhrGet({
				url : "/" + gCurDB + "/agtReplicateWF?OpenAgent&ID=" + id,
				handleAs : "text",
				preventCache : true,
				load : function(txt) {
					if (parseInt(txt) == 1) {
						alert("复制成功！");
						OpenWF()
					}
					dijit.byId('oWFDlg').onCancel();
				},
				error : function(response) {
					alert("无法复制，可能服务器异常或网络不通！");
				}
			})
		}
	}
// -->
</script>


</head>
<body text="#000000" bgcolor="#FFFFFF" oncontextmenu='return true'
	onselectstart='return true' class="soria"
	onload="Application(BasePath+'/config/graph-edit.xml');">

	<form method="post"
		action="${pageContext.request.contextPath}/admin/updateWorkFlow.action"
		name="_fmWorkFlow">
		<div style="display:none">
			<br>

			<textarea name="workFlow.wfProcessXml" id="WFProcessXML" rows="7"
				cols="50">
				<c:choose>
				   <c:when test="${empty workFlow }">
				   		<Process />
				   </c:when>
				   <c:otherwise>
				    	${workFlow.wfProcessXml }
				    </c:otherwise>
				</c:choose>
			</textarea>
			<br>
			<textarea name="workFlow.wfGraphXml" id="WFGraphXML" rows="7"
				cols="50">
				<c:choose>
				   <c:when test="${empty workFlow}">
				   		<GraphModel><root><Cell id='0' /><Cell id='1' parent='0' /></root></GraphModel>
				   </c:when>
				   <c:otherwise>
				    	${workFlow.wfGraphXml }
				    </c:otherwise>
				</c:choose>
				
			</textarea>
		</div>

		<script type="text/javascript">
			var gbIsCreateNew = true;
		</script>



		<div id="page" style="width:100%;height:100%"
			dojoType="dijit.layout.BorderContainer" design="sidebar"
			gutters="false">
			<div dojoType="dojox.layout.ExpandoPane" splitter="true"
				duration="125" title="流程导航" region="leading" maxWidth="275"
				style="width:220px">
				<div jsId="ifrStore" dojoType="ext/data/DominoItemFileReadStore"
					data-dojo-props='url:"/HTOA/admin/findAllWF.action"'
					urlPreventCache="true"></div>
				<div jsId="ifrModel" dojoType="dijit/tree/ForestStoreModel"
					data-dojo-props='store:ifrStore, query:{pid:"-1"},
		rootId:"continentRoot", rootLabel:"Continents", childrenAttrs:["children"]'></div>
				<div id="NavWorkFlowTree" dojoType="dijit/Tree" model="ifrModel"
					showRoot="false" persist="true" openOnClick="true"
					style="padding:5px;border-right:1px solid #959596;width:100%;height:99%">

					<script type="dojo/method" data-dojo-event="onClick"
						data-dojo-args="item">
			
	var type=ifrStore.getValue(item, "type");
	if(type=="menu"){
		dojo.byId('menuId').value = ifrStore.getValue(item, "id");
	}else if(type == "workFlow" ){
		window.location="/HTOA/admin/getWorkFlowById.action?wfId="+ifrStore.getValue(item, "id");
	}
</script>

<script type="dojo/method" event="getIconStyle" args="item">
	if(item&&item.status){
		var ico="";
		if(item.status=="active"){
			ico="82";
		}else{
			ico="80";
		}
		return {background:"url(/icons/vwicn0"+ico+".gif) no-repeat 50% 50%"}
	}
	return null;
</script>
				</div>
			</div>
			<div id="header" dojoType="dijit.layout.ContentPane" region="top"
				splitter="false">
				<div
					style="background:url(/HTOA/js/workflow/images/bgToolsBar.gif) #efefef repeat-x;height:49px;border:1px solid #959596;border-width:0px 1px;">
					<div id="basicActions"></div>
					<div id="toolbar"></div>
					<div id="mainActions"></div>
					<div id="attrWF"></div>
					<div id="divSource">
						<input id="source" type="checkbox" />图形源码
					</div>
				</div>
			</div>
			<div dojoType="dijit.layout.ContentPane" region="center"
				style="border:1px solid #959596">
				<div id="graph"
					style="background-image:url(/HTOA/js/workflow/images/bgGraph.gif)"></div>
				<textarea id="GraphXML"></textarea>
			</div>
		</div>
		<div dojoType="dijit.Dialog" title="流程信息" id="oWFDlg"
			onfocus="try{dojo.byId('WFName').focus()}catch(e){}"
			style="display:none">
			<div dojoType="dijit.layout.BorderContainer" gutters=false
				style="width:500px;height:350px;">
				<div dojoType="dijit.layout.TabContainer" region="top"
					style="height:280px;width:480px">
					<div dojoType="dijit.layout.ContentPane" title="基本信息">
						<table style="width:450px;text-align:left" border=0 cellspacing=0
							cellpadding=0>
							<tr height=40px style="display:none">
								<td class="LabelText"></td>
								<td class="TextL">
									菜单id：<input name="menuId" id="menuId" type="hidden" value="${workFlow.menu.uuid}"/>
									流程id<input name="workFlow.uuid" id="wfId" type="hidden" value="${workFlow.uuid}"/>
								</td>
							</tr>
							<tr height=40px>
								<td class="LabelText">流程名称：</td>
								<td class="TextL"><input name="workFlow.wfName" id="WFName"
									value="${workFlow.wfName}"></td>
							</tr>
							<tr height=40px>
								<td class="LabelText">状态：</td>
								<td class="TextL"><select name="workFlow.wfStatus"
									id="WFStatus">
										<option value="0">冻结
										<option value="1" selected>活动
								</select></td>
							</tr>
							<tr height=40px>
								<td class="LabelText">版本：</td>
								<td class="TextL"><input name="workFlow.wfVersion"
									value="${workFlow.wfVersion}"
									onkeyup="this.value=this.value.replace(/[^\d]/g,'')"
									id="WFVersion"
									onbeforepaste="this.value=clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"></td>
							</tr>
						</table>
					</div>
					<div dojoType="dijit.layout.ContentPane" title="其它">
						<table style="width:450px;text-align:left" border=0 cellspacing=0
							cellpadding=0>

						</table>
					</div>
				</div>
				<div dojoType="dijit.layout.ContentPane" region="center"
					style="height:40px"'>
					<div class="dijitDialogPaneActionBar" style="text-align:right">
						<button dojoType="dijit.form.Button" type="button"
							onclick="SaveWF();dijit.byId('oWFDlg').onCancel()">保存</button>
						<button dojoType="dijit.form.Button" type="button"
							onclick="fnReplicateWF('245F51771517F69548257D9C003A3DAC')">复制</button>
						<button dojoType="dijit.form.Button" type="button"
							onclick="fnDelWF('245F51771517F69548257D9C003A3DAC')">删除</button>
						<button dojoType="dijit.form.Button" type="button"
							onclick="dijit.byId('oWFDlg').onCancel()">取消</button>
					</div>
				</div>
			</div>
	</form>
</body>
</html>
